#include "Move.h"

Move::Move( unsigned int from, unsigned int to, unsigned int flags )
{
	m_Move = ((flags & 0xf)<<12) | ((from & 0x3f)<<6) | (to & 0x3f);
}

void Move::operator=( Move a )
{
	 m_Move = a.m_Move;
}


unsigned int Move::getTo() const
{
	return m_Move & 0x3f;
}

unsigned int Move::getFrom() const
{
	return (m_Move >> 6) & 0x3f;
}

unsigned int Move::getFlags() const
{
	return (m_Move >> 12) & 0x0f;
}

void Move::setTo(unsigned int to)
{
	m_Move &= ~0x3f;
	m_Move |= to & 0x3f;
}

void Move::setFrom(unsigned int from)
{
	m_Move &= ~0xfc0;
	m_Move |= (from & 0x3f) << 6;
}

bool Move::isCapture() const
{
	return (m_Move & CAPTURE_FLAG) != 0;
}

bool Move::operator==(Move a) const
{
	return (m_Move & 0xffff) == (a.m_Move & 0xffff);
}

bool Move::operator!=(Move a) const
{
	return (m_Move & 0xffff) != (a.m_Move & 0xffff);
}

unsigned short Move::asShort() const
{
	return (unsigned short) m_Move;
}